package com.itcast.fjs.controller;

import com.itcast.fjs.feign.UserClient;
import com.itcast.fjs.pojo.User;
import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;
import java.net.URI;
import java.util.List;

/**
 * @author feng js
 */
@RestController
@RequestMapping("consumer")
public class UserController {

    @Autowired
    UserClient userClient;

    @GetMapping("{id}")
    public String findUser(@PathVariable("id") Integer id, HttpServletRequest request) {
        String name = request.getHeader("name");
        System.out.println("name = " + name);
        String user = userClient.findUser(id);

        return user;
    }

}
